﻿using AppFramework;
using AppFramework.Demo;
using AppFramework.DinosaursParkMes.Execute;
using AppFramework.DinosaursParkMes.Execute.Dto;
using AppFramework.Shared;
using AppFramework.Version.Dtos;
using Models.DinosaursParkMes.Production;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Media3D;
using System.Windows.Threading;

namespace ViewModels.DinosaursParkMes.Execute
{
    public class ExecuteViewModel: NavigationCurdViewModel
    {
        private readonly IExecuteScheduleAppService appService;
        private readonly ExecuteDto executeDto;

        public ExecuteViewModel(IExecuteScheduleAppService appService, ExecuteDto executeDto)
        {
            Title = Local.Localize("Execute");
            this.appService = appService;
            this.executeDto = executeDto;

            var priority = new DispatcherPriority();
            priority = DispatcherPriority.Send;//设置优先级为最高（按需）
            DispatcherTimer timer = new DispatcherTimer(priority);
            timer.Interval = new TimeSpan(0, 0, 0, 1);
            timer.Tick += timer_Tick;
            timer.IsEnabled = true;

        }


        /**************************************************************/
        /*当前日期*/
        private string _DateNow;
        public string DateNow
        {
            get { return _DateNow; }
            set { _DateNow = value; OnPropertyChanged(); }
        }
        /*当前时间*/
        private string _TimeNow;
        public string TimeNow
        {
            get { return _TimeNow; }
            set { _TimeNow = value; OnPropertyChanged(); }
        }
        /*事件处理器*/
        private void timer_Tick(object sender, EventArgs e)
        {
            DateNow = DateTime.Now.ToString("yyyy-MM-dd ");
            TimeNow = DateTime.Now.ToString("HH:mm:ss");
        }



        /// <summary>
        /// 进度列表
        /// </summary>
        /// <returns></returns>
        private async Task GetExecutes()
        {
            await SetBusyAsync(async () =>
            {
                await appService.GetExecutes().WebAsync(dataPager.SetList);
            });
        }
        public override async Task OnNavigatedToAsync(NavigationContext navigationContext=null)
        {
            await SetBusyAsync(async () =>
            {
                await GetExecutes();
            });
        }


    }
}
